/**
 * Created with IntelliJ IDEA.
 * Description: “异常” 学习
 */
class SignIn{
    private String userName = "zhangsan";
    private String password = "123456";

    public void signIn(String userName,String password) {
        if (!this.userName.equals(userName))
            throw new UserNameException("用户名错误");
        if (!this.password.equals(password))
            throw new PasswordException("密码错误");
        System.out.println("登录成功！");
    }
}

public class Test {
    public static void main(String[] args) {
        SignIn signIn = new SignIn();
        try{
            signIn.signIn("zhangsan","123456");
        }catch(UserNameException e){
            System.out.println(e);
        }catch (PasswordException e){
            System.out.println(e);
        }
    }

}
